package com.wlyuan.index.domain.index.valueobj;

import com.wlyuan.core.marker.INamed;
import com.wlyuan.core.marker.NamedMap;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.var;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * @author yuanjie
 */
@Deprecated
@AllArgsConstructor
@Getter
public enum WaybillStatus implements INamed<Integer> {

    WAIT_SIGN(30, "待签收"),
    LOCK_SIGN(31, "签收中"),
    WAIT_RECEIPT(40, "待回单"),
    RECEIPTED(50, "已回单"),
    CLOSED(60, "已关闭");


    private final Integer value;
    private final String name;


    public static final List<WaybillStatus> CAN_BILL = Arrays.asList(WAIT_SIGN, LOCK_SIGN, WAIT_RECEIPT, RECEIPTED);
    public static final List<WaybillStatus> CAN_QUOTE = Arrays.asList(WAIT_SIGN, LOCK_SIGN, WAIT_RECEIPT, RECEIPTED);
    private static final Map<Integer, WaybillStatus> STATUSES = new NamedMap<>(WaybillStatus.values());

    public static WaybillStatus valueOf(Integer value) {
        return STATUSES.get(value);
    }

    public static boolean canQuote(Integer value) {
        var status = valueOf(value);
        return CAN_QUOTE.contains(status);
    }

    public static boolean canBill(Integer value) {
        var status = valueOf(value);
        return CAN_BILL.contains(status);
    }

    public static boolean endQuote(Integer value) {
        return CLOSED == valueOf(value);
    }
}
